package com.learn.composite;

import com.learn.composite.safe.SComposite;
import com.learn.composite.safe.SLeaf;
import com.learn.composite.transparent.Composite;
import com.learn.composite.transparent.Leaf;
import lombok.extern.slf4j.Slf4j;

/**
 * <p>项目名称: design-pattern </p>
 *
 * <p>文件名称: App </p>
 *
 *
 */
@Slf4j
public class App {

    public static void main(String[] args) {

        log.info("-------------------------透明模式-----------------------------------------");
        Composite composite = new Composite("我的文件");
        Composite composite2 = new Composite("我的电影");
        Composite composite3 = new Composite("我的照片");
        Leaf l1 = new Leaf("xxx.word");
        Leaf l2 = new Leaf("yyt.avi");
        Leaf l3 = new Leaf("yyt.jpeg");
        Leaf l4 = new Leaf("zzz.jpeg");

        composite.add(composite2);
        composite.add(composite3);
        composite.add(l1);
        composite2.add(l2);
        composite3.add(l3);
        composite3.add(l4);

        composite.display(0);

        log.info("-------------------------安全模式-----------------------------------------");

        SComposite sc1 = new SComposite("我的文件SS");
        SComposite sc2 = new SComposite("我的电影SS");
        SComposite sc3 = new SComposite("我的照片SS");
        SLeaf sl1 = new SLeaf("SS-xxx.word");
        SLeaf sl2 = new SLeaf("SS-yyt.avi");
        SLeaf sl3 = new SLeaf("SS-yyt.jpeg");
        SLeaf sl4 = new SLeaf("SS-zzz.jpeg");

        sc1.add(sc2);
        sc1.add(sc2);
        sc1.add(sl1);
        sc2.add(sl2);
        sc2.add(sl3);
        sc3.add(sl4);

        sc1.display(0);
    }
}
